\begin{tikzpicture}[>=Stealth]
    \draw [dashed] (0, -1) -- (pi, -1) -- (pi, 0);

    \draw [->] (-pi-0.5, 0) -- (1.5*pi+0.5, 0) node[anchor=west] {$x$};
    \draw [->] (0, -1.5) -- (0, 1.5) node[anchor=east] {$y$};
    \node [font=\footnotesize, fill=white, inner sep=0pt] at (0.3, -0.3) {$O$};
    \draw (0,1) -- (0.2, 1) node [font=\footnotesize] at (-0.2, 0.8) {$1$};
    \draw (0,-1) -- (0.2, -1) node [font=\footnotesize] at (-0.3, -1) {$-1$};
    \foreach \x / \name in {
        -0.5*pi/$-\dfrac{\pi}{2}$,
        0.5*pi/$\dfrac{\pi}{2}$,
        pi/$\pi$} {
        \draw (\x, 0) -- (\x, 0.2);
        \node [anchor=south, font=\footnotesize, fill=white, inner sep=1pt] at (\x, 0) {\name};
    }

    \draw[domain=-0.9*pi:1.5*pi,samples=50,smooth] plot (\x, {cos(\x r)});
    \node at (1, 1.2) {$y = \cos x$};
\end{tikzpicture}
